//我的解法
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n = 0;
        int sum = 0;
        int num = 0;
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                num = sc.nextInt();
                if(i == j){
                    sum += num;
                }
            }
        }
        System.out.println(sum);
    }
}

//官方题解
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int answer = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int num = sc.nextInt();
                if (i == j) {
                    answer += num;
                }
            }
        }

        System.out.println(answer);
    }
}
//怎么都找不到原因，最后一看，是没有对n初始化